package com.icinfo.cloud.provider.punish.dto;

import com.icinfo.cloud.provider.punish.vo.AssociatedTaskPartiesVo;
import com.icinfo.cloud.provider.punish.vo.TaskClientVO;
import lombok.Data;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author: Kexin.Hu
 * @date: 2024/3/6 17:35
 */
@Data
public class CheckObjectDetailVo {

    /**
     * 主键
     */
    private String id;

    /**
     * 检查任务名称
     */
    private String name;

    /**
     * 检查对象（当事人）详情
     */
    List<AssociatedTaskPartiesVo> partiesVos;

    public static CheckObjectDetailVo convertByTaskClientVO(TaskClientVO data) {
        CheckObjectDetailVo vo = new CheckObjectDetailVo();
        if (Objects.isNull(data)) {
            return vo;
        }
        vo.setId(data.getTaskUid());
        vo.setName(data.getTaskName());
        List<AssociatedTaskPartiesVo> partiesVoList = data.getClients().stream().map(AssociatedTaskPartiesVo::convertForCheckTask).collect(Collectors.toList());
        vo.setPartiesVos(partiesVoList);
        return vo;
    }

}
